//Error in fgets - "wrong number of arguments"

module IOManager (Access, Address, Operation);

input Access;
output Operation, Address;

reg [31:0] Address;
reg [3:0] Operation;

parameter Read = 4'b0000;   //For input and output, is LRU indicator for output
parameter Write = 4'b0001;
parameter InstructionFetch = 4'b0010;
parameter Invalidate= 4'b0011;
parameter Flush = 4'b1000;
parameter State = 4'b1001;

integer file, n, eof;
//if (Access)
initial
file = $fopen("Trace.txt", "r");				//convert from hex to binary.  feed address into cache module
											//address , enable (4 bit encoded value (0-9).  
											// every time access high, reads one 

always @(posedge Access) 
begin : ReadFile 

//eof = $fgets(String, m, "trace.txt"); //does this pick up just 1st character?  so 

//eof = $fgets(n, 16, file);
reg[127:0] str;
integer op;
reg [7:0] hex[7:0];
reg [7:0] a,b,c,d,e,f,g,h;

eof = $fgets(str, file);
$sscanf(str,"%d %c%c%c%c%c%c%c%c\n",op,a,b,c,d,e,f,g,h);
$display("String is %d %c%c%c%c%c%c%c%c\n",op,a,b,c,d,e,f,g,h);

//atoi, output Address
/*
case (n)

'0':  //read data request from L1 cache
	Operation = Read;
'1':	//write data request from L1 cache
	Operation = Write;
'2':	//instruction fetch (treated like #0)
	Operation = InstructionFetch;
'3':  //invalidate command from L2
	Operation = Invalidate;
'8':	//clear the cache and reset all state
	Operation = Flush;
'9':	//print contents and state of the cache
	Operation = State;
	

	*/
end
endmodule 

